package com.example.video.controller;

import com.example.video.common.ResultModel;
import com.example.video.service.inter.IFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
@RequestMapping("/upload")
@Api(value = "上传相关接口", tags = {"UploadController"})
public class UploadController {


    private final IFileService fileService;

    @Autowired
    public UploadController(IFileService fileService) {
        this.fileService = fileService;
    }


    /**
     * 后台OSS上传参数
     */
    @RequiresUser
    @RequestMapping(value = "/ossUpload", method = GET)
    @ApiOperation(value = "获取OSS上传参数")
    public Object ossUpload() {
        return ResultModel.ok(fileService.getPostObjectPolicy("video/upload/"));
    }

}
